package app.rci.util;

import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import net.sourceforge.stripes.localization.DefaultLocalePicker;

public class MygsetLocalPicker extends DefaultLocalePicker {
	
	private final static String SELECTED_LOCALE = "__selectedLocale";

	@Override
	public Locale pickLocale(HttpServletRequest request) {
        HttpSession session = request.getSession();
        Locale locale = (Locale) session.getAttribute(SELECTED_LOCALE);
        if(locale != null){
        	return locale;
        } else {
        	locale = super.pickLocale(request);
        	session.setAttribute(SELECTED_LOCALE, locale);
            return locale;        
        }
	}
}
